package com.lfy.spring.dao;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * @author leifengyang
 * @version 1.0
 * @date 2025/8/9 20:19
 * @description:
 */
@Repository
public class UserDao {


    @Transactional(isolation = Isolation.READ_UNCOMMITTED,
            propagation = Propagation.REQUIRES_NEW,timeout = 5000)
    public void helloUser(){
        System.out.println("helloUser");

        //运行时异常；不受检异常；编译器不检查。

        //helloUser();

        int i = 10/0;
        try {
            //编译时异常：受检异常；编译器会检查
            new FileOutputStream("D://haha.txt");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
